<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="s_part" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="establishRelationSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 关键件关系 </span>
      </div>
      <el-table :data="pageList" v-loading="loading" @selection-change="handleSelectionChange">
        <el-table-column label="#" align="center" type='selection'>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="适用性" prop="part_relation">
          <template slot-scope="scope">
            {{getValueName("非全适用=1,全适用=2",scope.row.part_relation)}}
          </template>
        </el-table-column>
        <el-table-column label="类别" prop="part_type">
          <template slot-scope="scope">
            {{getValueName("A类=1,B类=2",scope.row.part_type)}}
          </template>
        </el-table-column>
        <el-table-column label="证书号" prop="part_num">
        </el-table-column>
        <el-table-column label="名称" prop="part_name">
        </el-table-column>
        <el-table-column label="型号" prop="part_model">
        </el-table-column>
        <el-table-column label="规格" prop="part_norm">
        </el-table-column>
        <el-table-column label="供应商" prop="client_name">
        </el-table-column>
        <el-table-column label="生产厂家" prop="enterprise_desc">
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'EstablishRelation',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_part: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      establishRelationSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/certificate/CertificateAction/establishRelationSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      getPage(page) {
        this.loading = true;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/s_part?' + this.vueparams,
          params: {
            pageNo: page
          }
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["part_id"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
